package com.laomou.password;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;

public class PasswordHelper {
    private HashMap<String, IPassword> mPasswordHelper = new HashMap();

    public PasswordHelper(Context context) {
        regPasswordHelper(new WeiboPasswordHelper(context));
    }

    private void regPasswordHelper(IPassword password) {
        if (!mPasswordHelper.containsKey(password.getPackage())) {
            mPasswordHelper.put(password.getPackage(), password);
        }
    }

    public IPassword handlePassword(CharSequence pkg) {
        if (mPasswordHelper.containsKey(pkg)) {
        	return mPasswordHelper.get(pkg);
        }
        return null;
    }

    public String[] getPackageNames() {
        ArrayList<String> pkgs = new ArrayList();
        for (String pkg : mPasswordHelper.keySet()) {
            pkgs.add(pkg);
        }
        return pkgs.toArray(new String[pkgs.size()]);
    }
}
